/*
* File: interp.c
* --------------
* This program simulates the top level of a programming
* language interpreter.  The program reads an expression,
* evaluates the expression, and displays the result.
*/

#include <stdio.h>
#include "genlib.h"
#include "exception.h"
#include "strlib.h"
#include "simpio.h"
#include "exp.h"
#include "eval.h"
#include "parser.h"
#include "scanadt.h"
#include "commands.h"

void initProgram(string program[]);
/* Main program */

main(){
	scannerADT scanner;
	string line;

	printf("Minimal BASIC -- Type HELP for help.\n\n");
	initProgram(program);
	InitCommandTable();
	InitVariableTable();
	scanner = NewScanner();
	SetScannerSpaceOption(scanner, IgnoreSpaces);
	while (TRUE) {
		try {
			line = GetLine();
			SetScannerString(scanner, line);

			parseCommand(scanner, line);

			//exp = ParseExp(scanner);
			//value = EvalExp(exp);
			//printf("%d\n", value);

			except(ErrorException)
				printf("Error: %s\n", (string) GetExceptionValue());

		} endtry
	}
}

void initProgram(){
	int i;

	for(i = 1; i <= NUMBER_OF_LINES; i++){
		program[i] = "NULL";
	}
}